<?php

use app\middleware\SystemMiddleware;
use think\facade\Route;
use think\middleware\AllowCrossDomain;
use think\middleware\CheckRequestCache;
use think\middleware\SessionInit;

$middleware = [
    //     全局请求缓存
//    CheckRequestCache::class,
//     Session初始化
    SessionInit::class,
    AllowCrossDomain::class
];

Route::group("system", function () {
    Route::post("login", "system.account/login")->option(['real_name' => '账号登录']);
    Route::group("area", function () {
        Route::get("tree", "system.area/tree");
        Route::get("province", "system.area/province");
        Route::get("city", "system.area/city");
        Route::get("gas", "system.area/gasProvince");
    });
    Route::get("station_edit_conf", "system.station/editCondition");
})->middleware($middleware);

Route::group("system", function () {
    Route::group("account", function () {
        Route::get("query", "system.account/query")->option(['real_name' => '账号查询']);
        Route::get("lst", "system.account/lst");
        Route::get("detail", "system.account/detail");
        Route::get("search", "system.account/search");
        Route::post("save", "system.account/save");
        Route::post("delete", "system.account/delete");
        Route::post("modify", "system.account/modify");
    })->option(['real_name' => '账号管理']);
    Route::group("power", function () {
        Route::post("save", "system.role/save");
        Route::get("lst", "system.role/lst");
        Route::get("query", "system.role/query");
        Route::post("delete", "system.role/delete");
        Route::get("select", "system.role/search");
    })->option(['real_name' => '权限管理']);
    Route::group("merchant", function () {
        Route::post("save", "system.merchant/save");
        Route::get("lst", "system.merchant/lst");
        Route::get("detail", "system.merchant/detail");
        Route::get("search", "system.merchant/search");
        Route::post("update_balance", "system.merchant/update_balance");
        Route::get("balance", "system.merchant/balance");
        Route::post('service_save','system.merchant/serviceSave');
        Route::get('service_lst','system.merchant/serviceLst');
        Route::get('service_detail','system.merchant/serviceDetail');
    })->option(['real_name' => '商家管理']);
    Route::group("gas", function () {
        Route::group("station", function () {
            Route::get("lst", "system.station/lst");
            Route::get("detail", "system.station/detail");
            Route::post("add_balance","system.station/add_balance");
            Route::post("save", "system.station/save");
            Route::get("city", "system.station/stationCity");
            Route::get("task_lst", "system.station/task_lst");
            Route::post("task_save", "system.station/addTask");
            Route::get("search","system.station/search");
            Route::get("account","system.station/account");
            Route::post("accountSave","system.station/account_save");
            Route::get("account_detail","system.station/account_detail");
            Route::post("typeSave","system.station/typeSave");
            Route::get('typeLst','system.station/typeLst');
            Route::get('typeDetail','system.station/typeDetail');
            Route::post('brandSave',"system.station/brandSave");
            Route::get('brandLst','system.station/brandLst');
            Route::get('brandDetail','system.station/brandDetail');
        });
    });
    Route::group("supplier", function () {
        Route::post("save", "system.supplier/save");
        Route::get("lst", "system.supplier/lst");
        Route::get("detail", "system.supplier/detail");
        Route::post("balance", "system.supplier/balance");
        Route::get("balance_lst", "system.supplier/balance_lst");
        Route::get("search", "system.supplier/search");
        Route::get("supplier_station_id", "system.supplier/supplier_station_ids");
        Route::post("supplier_station_save/:type","system.supplier/station");
        Route::get("supplier_station_lst","system.supplier/station_lst");
        Route::get("rule_lst","system.supplier/priceRuleLst");
        Route::post("save_rule","system.supplier/priceRuleSave");
        Route::get("rule_detail","system.supplier/priceRuleDetail");
        Route::delete('rule_delete',"system.supplier/deleteRule");
        Route::post('update_rule_state',"system.supplier/updateRuleState");
        Route::post("update_rule_price_config","system.supplier/rule_config");
    });
    Route::group("user",function (){
        Route::post("save","system.user/save");
        Route::get("lst","system.user/lst");
        Route::get("detail","system.user/detail");
        Route::post("updateState","system.user/update_state");
        Route::post("delete","system.user/delete");
        Route::post("updateBalance","system.user/update_balance");
        Route::get("balanceLst","system.user/balance_lst");
    });
    Route::group("order",function (){
        Route::get("lst","system.order/lst");
        Route::get("detail","system.order/detail");
        Route::post("refund","system.order/refund");
        Route::post("download","system.order/download");
    });

    Route::group("tip",function (){
        Route::post("save","system.tip/save");
        Route::get("tip_lst","system.tip/tip_lst");
        Route::get("detail","system.tip/detail");
        Route::delete("delete","system.tip/delete");
    })->name('tip');

    Route::group("oil_category",function (){
        Route::post("save","system.oil_category/save");
        Route::get("lst","system.oil_category/lst");
        Route::get("detail","system.oil_category/detail");
        Route::get("search","system.oil_category/search");
    });
    Route::group("oil_number",function (){
        Route::post('save',"system.oil_number/save");
        Route::get('lst',"system.oil_number/pageData");
        Route::get('detail',"system.oil_number/detail");
        Route::get('search',"system.oil_number/search");
    });
    Route::group("operation",function (){
        Route::post("save","system.operation/save");
        Route::get("lst","system.operation/lst");
        Route::get("detail","system.operation/detail");
    });

    Route::group("rebate",function (){
        Route::post("save","system.rebate/save");
        Route::get("lst","system.rebate/lst");
        Route::get("detail","system.rebate/detail");
        Route::get("search","system.rebate/search");
        Route::post("rule_save","system.rebate/rule_save");
        Route::get("rule_lst","system.rebate/rule_lst");
        Route::get("rule_detail","system.rebate/rule_detail");
    });
    Route::group("price",function (){
        Route::post("save","system.price/save");
        Route::get("lst","system.price/lst");
    });
})->middleware(array_merge($middleware, [SystemMiddleware::class]));
